"""
    加上通信循环的socket
"""
import socket

# 1. 买手机
phone = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# 2. 拨号
phone.connect(("127.0.0.1", 8080))

# 3. 发、收消息
while True:  # 通信循环
    msg = input(">>").strip()
    if "exit" in msg:
        break
    phone.send(msg.encode("utf-8"))
    data = phone.recv(1024)
    print(f"recv data : ", end="")
    print(data.decode("utf-8"))

# 4. 关机
phone.close()
